package com.zidongxiangxi.clock.server.manager;

import com.zidongxiangxi.clock.server.repository.entity.Clock;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * 闹钟任务管理类
 *
 * @author chenxudong
 * @date 2020/07/31
 */
@Component
public class ClockTaskManger {
    /**
     * 需要处理的闹钟任务
     */
    private static final CopyOnWriteArrayList<Clock> CLOCK_TASK = new CopyOnWriteArrayList<>();

    public void addClockTask(Clock alarmClock) {
        CLOCK_TASK.add(alarmClock);
    }

    public void addClockTask(List<Clock> alarmClocks) {
        CLOCK_TASK.addAll(alarmClocks);
    }

    public void removeClockTask(List<Clock> alarmClocks) {
        CLOCK_TASK.removeAll(alarmClocks);
    }

    public CopyOnWriteArrayList<Clock> getClockTask() {
        return CLOCK_TASK;
    }

}
